﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide.ui {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import Classes.*;
    import com.greensock.*;
    import Display.*;
    import Modules.guide.*;

    public class GuideMask extends Sprite {

        private static const MASK_TYPE_NONE:int = 0;
        private static const MASK_TYPE_NORMAL:int = 1;
        private static const MASK_TYPE_SPOTLIGHT:int = 2;

        private var m_shown:Boolean = false;
        private var m_maskType:int = 0;
        private var m_bgAlpha:Number = 0;
        private var m_showOutline:Boolean = false;
        private var m_spotCenter:Point;
        private var m_spotSize:Point;
        private var m_spotStyle:int;
        private var m_tweenTime:Number = 0.3;

        public function getMaskType():int{
            return (this.m_maskType);
        }
        public function setTweenTime(_arg1:Number):void{
            this.m_tweenTime = _arg1;
        }
        public function displayMaskWithParent(_arg1:DisplayObjectContainer, _arg2:int=-1, _arg3:Boolean=true):void{
            var _local4:Point;
            var _local5:Graphics;
            if (((!(this.m_shown)) && (!((_arg1 == null))))){
                _arg1.addChild(this);
                if (_arg2 != -1){
                    _arg1.setChildIndex(this, _arg2);
                } else {
                    _arg1.setChildIndex(this, (numChildren - 1));
                };
                if (_arg3){
                    this.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                    this.addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove, false, 0, true);
                    this.addEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver, false, 0, true);
                    this.addEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut, false, 0, true);
                };
                this.m_shown = true;
                this.m_maskType = MASK_TYPE_NORMAL;
                _local4 = this.globalToLocal(new Point(0, 0));
                _local5 = this.graphics;
                _local5.clear();
                _local5.beginFill(0, 0.75);
                _local5.drawRect(_local4.x, _local4.y, _arg1.width, _arg1.height);
                _local5.endFill();
                TweenLite.from(this, this.m_tweenTime, {alpha:0});
            };
        }
        public function displayMask(_arg1:int=0, _arg2:Number=0, _arg3:Boolean=false):void{
            if (!this.m_shown){
                switch (_arg1){
                    case GuideConstants.MASK_GAME_AND_BOTTOMBAR:
                        Global.ui.addChildAt(this, (Global.ui.numChildren - 1));
                        this.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut, false, 0, true);
                        break;
                    case GuideConstants.MASK_ALL_UI:
                        Global.ui.addChild(this);
                        Global.ui.setChildIndex(this, (Global.ui.numChildren - 1));
                        this.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut, false, 0, true);
                        break;
                    case GuideConstants.MASK_GAME:
                    default:
                        Global.ui.addChildAt(this, 0);
                };
                this.m_shown = true;
                this.m_maskType = MASK_TYPE_NORMAL;
                this.m_bgAlpha = _arg2;
                this.m_showOutline = _arg3;
                this.redrawMask();
                TweenLite.from(this, this.m_tweenTime, {alpha:0});
            };
        }
        public function removeMask():void{
            if (((this.m_shown) && (!((this.parent == null))))){
                TweenLite.to(this, this.m_tweenTime, {
                    alpha:0,
                    onComplete:this.onFinishRemoveMask
                });
            };
        }
        private function onFinishRemoveMask():void{
            parent.removeChild(this);
            removeEventListener(MouseEvent.CLICK, this.onMaskClicked);
            removeEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove);
            removeEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver);
            removeEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut);
            UI.popBlankCursor();
            this.m_shown = false;
            this.m_spotCenter = null;
            this.m_spotSize = null;
            this.m_maskType = MASK_TYPE_NONE;
        }
        public function displaySpotLight(_arg1:DisplayObjectContainer, _arg2:Point, _arg3:Point, _arg4:int, _arg5:int=0, _arg6:Number=0, _arg7:Boolean=false):void{
            if (((!(this.m_shown)) && (!((_arg1 == null))))){
                switch (_arg5){
                    case GuideConstants.MASK_GAME:
                    default:
                        _arg1.addChildAt(this, 0);
                        break;
                    case GuideConstants.MASK_GAME_AND_BOTTOMBAR:
                        _arg1.addChildAt(this, (_arg1.numChildren - 1));
                        this.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut, false, 0, true);
                        break;
                    case GuideConstants.MASK_ALL_UI:
                        _arg1.addChild(this);
                        _arg1.setChildIndex(this, (_arg1.numChildren - 1));
                        this.addEventListener(MouseEvent.CLICK, this.onMaskClicked, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut, false, 0, true);
                        break;
                    case GuideConstants.MASK_LOT_SITES:
                        _arg1.addChildAt(this, 0);
                        this.addEventListener(MouseEvent.MOUSE_UP, this.onLotSitesUp, false, 0, true);
                        this.addEventListener(MouseEvent.MOUSE_MOVE, this.onLotSitesMove, false, 0, true);
                        break;
                    case GuideConstants.MASK_NO_LISTEN:
                        _arg1.addChild(this);
                        _arg1.setChildIndex(this, (_arg1.numChildren - 1));
                };
                this.m_shown = true;
                this.m_maskType = MASK_TYPE_SPOTLIGHT;
                this.m_spotCenter = _arg2;
                this.m_spotSize = _arg3;
                this.m_spotStyle = _arg4;
                this.m_bgAlpha = _arg6;
                this.m_showOutline = _arg7;
                this.redrawMask();
            };
        }
        public function clearEventListener():void{
            if (this.hasEventListener(MouseEvent.CLICK)){
                this.removeEventListener(MouseEvent.CLICK, this.onMaskClicked);
            };
            if (this.hasEventListener(MouseEvent.MOUSE_MOVE)){
                this.removeEventListener(MouseEvent.MOUSE_MOVE, this.onMaskMouseMove);
            };
            if (this.hasEventListener(MouseEvent.MOUSE_OVER)){
                this.removeEventListener(MouseEvent.MOUSE_OVER, this.onMaskMouseOver);
            };
            if (this.hasEventListener(MouseEvent.MOUSE_OUT)){
                this.removeEventListener(MouseEvent.MOUSE_OUT, this.onMaskMouseOut);
            };
        }
        public function resize():void{
            this.redrawMask();
        }
        private function redrawMask():void{
            var _local3:Point;
            var _local4:Rectangle;
            var _local5:Rectangle;
            var _local1:Point = this.globalToLocal(new Point(0, 0));
            var _local2:Graphics = this.graphics;
            _local2.clear();
            if (this.m_maskType == MASK_TYPE_SPOTLIGHT){
                _local3 = this.globalToLocal(this.m_spotCenter);
                _local4 = new Rectangle((_local3.x - (this.m_spotSize.x / 2)), (_local3.y - (this.m_spotSize.y / 2)), this.m_spotSize.x, this.m_spotSize.y);
                _local2.beginFill(0, this.m_bgAlpha);
                _local2.drawRect(_local1.x, _local1.y, stage.stageWidth, stage.stageHeight);
                if (this.m_spotStyle == GuideConstants.MASK_STYLE_RECTANGLE){
                    _local2.drawRoundRect(_local4.x, _local4.y, _local4.width, _local4.height, 5);
                } else {
                    _local2.drawEllipse(_local4.x, _local4.y, _local4.width, _local4.height);
                };
                _local2.endFill();
                if (this.m_showOutline){
                    _local5 = new Rectangle((_local4.x + 2), (_local4.y + 2), (_local4.width - 4), (_local4.height - 4));
                    _local2.lineStyle(5, EmbeddedArt.BORDER_MAIN_COLOR, 1, true);
                    if (this.m_spotStyle == GuideConstants.MASK_STYLE_RECTANGLE){
                        _local2.drawRoundRect(_local5.x, _local5.y, _local5.width, _local5.height, 5);
                    } else {
                        _local2.drawEllipse(_local5.x, _local5.y, _local5.width, _local5.height);
                    };
                };
            } else {
                _local2.beginFill(0, this.m_bgAlpha);
                _local2.drawRect(_local1.x, _local1.y, parent.width, parent.height);
                _local2.endFill();
            };
        }
        protected function onMaskClicked(_arg1:MouseEvent):void{
            _arg1.stopPropagation();
        }
        private function onMaskMouseMove(_arg1:MouseEvent):void{
            Global.ui.hideAnyToolTip();
            UI.pushBlankCursor();
            _arg1.stopPropagation();
        }
        private function onMaskMouseOver(_arg1:MouseEvent):void{
            UI.pushBlankCursor();
            _arg1.stopPropagation();
        }
        private function onMaskMouseOut(_arg1:MouseEvent):void{
            UI.popBlankCursor();
            _arg1.stopPropagation();
        }
        private function onLotSitesUp(_arg1:MouseEvent):void{
            _arg1.stopImmediatePropagation();
            _arg1.stopPropagation();
            Global.franchiseManager.placementMode = false;
        }
        private function onLotSitesMove(_arg1:MouseEvent):void{
            Global.world.getTopGameMode().onMouseMove(_arg1);
        }

    }
}//package Modules.guide.ui 
